<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/template/header.jsp"%>

<jsp:useBean id="goods" scope="request" class="com.pricecmp.model.Good"></jsp:useBean>
<jsp:useBean id="comments" scope="request" class="java.util.ArrayList"></jsp:useBean>
<jsp:useBean id="userCommect" scope="page"
	class="com.pricecmp.model.Comment"></jsp:useBean>

<div class="container">
	<div class="well ">
		<div class="row-fluid">
			<h1 class="redHead"><%=goods.getName()%></h1>
		</div>
		<div id="show_goods" class="row-fluid">
			<div class="span5">
				<img class="img-polaroid" src="<%=goods.getImgUrl()%>" alt="" />
			</div>
			<div class="span5">
				<h5>
					价格： <i class="price"><%=goods.getPrice()%></i>
				</h5>
				<h5>
					商家： <a href="<%=goods.getUrl()%>" target="_blank"><i><%=goods.getSource()%></i></a>
				</h5>
				<%
					if (isLogin.equals("yes")) {
				%>
				<a href="#commentModal" role="button"
					class="btn btn-mini btn-primary" data-toggle="modal">发表评论</a>
				<%
					} else {
				%>
				<h5>登录后可以发表评论</h5>
				<%
					}
				%>
			</div>
		</div>
		<div id="show_comment" class="row-fluid">
			<div class="tabbable">
				<ul class="nav nav-tabs">
					<li class="active"><a href="#comments" data-toggle="tab">用户评论</a></li>
				</ul>
				<div class="tab-content">
					<div class="tab-pane active" id="comments">
						<table class="table table-condensed table-bordered">
							<thead>
								<tr>
									<th>用户</th>
									<th>评论内容</th>
									<th>评论时间</th>
								</tr>
							</thead>
							<tbody>
								<%
									for (int i = 0; i < comments.size(); i++) {
										pageContext.setAttribute("userCommect", comments.get(i));
								%>
								<tr>
									<td><jsp:getProperty name="userCommect"
											property="authorName" /></td>
									<td><jsp:getProperty name="userCommect" property="content" /></td>
									<td><jsp:getProperty name="userCommect" property="time" /></td>
								</tr>
								<%
									}
								%>
							</tbody>
						</table>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>

<div id="commentModal" class="modal hide fade" tabindex="-1"
	role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<form action="<%=request.getContextPath() + "/search/launchcomment"%>"
		method="post">
		<div class="modal-header">
			<button type="button" class="close" data-dismiss="modal"
				aria-hidden="true">×</button>
			<h3 id="commentModalLabel">请填写评论</h3>
		</div>
		<div class="modal-body">
			<textarea rows="4" placeholder="请认真填写评论，垃圾评论将不予显示" name="content"></textarea>
			<input type="hidden" name="goodsid" value="<%=goods.getGoodId()%>" />
		</div>
		<div class="modal-footer">
			<button class="btn" data-dismiss="modal" aria-hidden="true">取消</button>
			<button type="submit" class="btn btn-primary">发布</button>
		</div>
	</form>
</div>

<%@include file="/template/footer.jsp"%>